package managerSIP;

import java.io.IOException;
import net.sf.asterisk.manager.AuthenticationFailedException;
import net.sf.asterisk.manager.TimeoutException;

public class InviteThread extends Thread {

    private int conf;

    private Manager man;

    public InviteThread(String name, int conference, Manager myMangr){
	super(name);
	this.conf = conference;
	this.man = myMangr;
    }

    public void run(){
	String response = null;
	try {
	    response = man.conferenceManager.inviteUser(getName(),this.conf);
	    System.out.println("InviteThread -- response: " + response);
	    //System.out.println("User "+this.getName()+" answers the call - "+response);
	} catch (IOException e) {
	    e.printStackTrace();
	} catch (AuthenticationFailedException e) {
	    e.printStackTrace();
	} catch (TimeoutException e) {
	    e.printStackTrace();
	}
	/*
		if (!response.equals("Success")); //!="Success") 
		{ 
			//?? Should we check something here??? like...
			// if (response==???) ...

			try {
				Thread.sleep(9000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			//System.out.println("User "+getName()+" answers the call - "+response);
			System.out.println("Entrando na thread reposta= "+response);

		}	
	 */	
    }

}
